from django.shortcuts import render
from django.views import View
from django.http.response import HttpResponse

class InfoCollection(View):
    def get(self,request):
        return render(request,'InfoCollection/form.html',{})
    
    def post(self,request):
        print('###',request.POST)
        user_info = {
            "name":request.POST.get('name'),
            "age":request.POST.get('age'),
            "sex":request.POST.get('sex'),
            "account":request.POST.get('account'),
            "password":request.POST.get('password'),
            "intro":request.POST.get('introduction'),
            "star":'*' * len(request.POST.get('password'))
        }
        return render(request,'InfoCollection/info.html',{"info":user_info})
    
    def put(self,request):
        data = '<h1>Put Requestion</h1>'
        return HttpResponse(data, content_type="text/html")
    
    def patch(self,request):
        data = '<h1>Patch Requestion</h1>'
        return HttpResponse(data, content_type="text/html")
    
    def delete(self,request):
        data = '<h1>Delete Requestion</h1>'
        return HttpResponse(data, content_type="text/html")